//
//  SMSRequestProvider.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/2/26.
//  
  

#import "SMSRequestProvider.h"
#import "SMSRequest.h"



@implementation SMSRequestProvider

+ (void)requestSmsWithPhoneNumber:(NSString *)number success:(void(^)(BOOL success))success failure:(void(^)(YTKRequest *request))failure {
    SMSRequest *request = [SMSRequest new];
    request.strides = number;
#ifdef DEBUG
    // request.strides = User.user.account;
#endif
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            !success ?: success(YES);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}



@end
